#include "netcheckmanager.h"
#include "icmpchecker.h"
#include "telnetchecker.h"

#include <iostream>
#include <unistd.h>

using namespace std;

int main()
{
    if (0 != getuid()) {
        cout << "need root run!" << endl;
        return 0;
    }

    NetCheckManager manager;
    manager.addChecker(std::make_shared<ICMPChecker>("udcp-web.uniontech.com"));
    manager.addChecker(std::make_shared<ICMPChecker>("www.baidu.cddom"));
    manager.addChecker(std::make_shared<ICMPChecker>("www.baidudd.com"), 2);
    manager.addChecker(std::make_shared<TelnetChecker>("udcp-web.uniontech.com", 4443), 1);

    int i = 10;
    while (i--) {
        sleep(1);
        manager.startCheck();
        std::cout << manager.netConnected() << std::endl;
    }

    return 0;
}
